# -*- coding: utf-8 -*-
"""
Created on Fri Dec 28 00:56:20 2018

@author: Cy
"""

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image


png = Image.open('D:/projects/tensorflow_models/verification-decoder/real-images/3Gmn.gif')
png.load() # required for png.split()

background = Image.new("RGB", png.size, (255, 255, 255))
background.paste(png, mask=png.split()[3]) # 3 is the alpha channel

background.save('foo.jpg', 'JPEG', quality=80)



from PIL import Image

png = Image.open(img_path).convert('RGBA')
background = Image.new('RGBA', png.size, (255,255,255))

alpha_composite = Image.alpha_composite(background, png)
alpha_composite.save('foo.jpg', 'JPEG', quality=80)